package com.nate.tasking.actions;

import javax.jdo.PersistenceManager;

import org.apache.log4j.Logger;

import com.nate.tasking.data.PMF;
import com.nate.tasking.domain.Project;
import com.opensymphony.xwork2.ActionSupport;


public class AddProjectAction extends ActionSupport {

	
	private static final long serialVersionUID = 6873040788453682095L;
	private final Logger logger = Logger.getLogger(AddProjectAction.class);
	private Project project;
	
	public String execute(){
		logger.debug("AddProjectAction start");
		
		logger.debug("adding project: " + project.getName());
		
		PersistenceManager pm = PMF.get().getPersistenceManager();
	    	try {
	            pm.makePersistent(project);
	            logger.debug("Project Added");
	        } finally {
	            pm.close();
	        }
		
		return SUCCESS;
	}

	public Project getProject() {
		return project;
	}

	public void setProject(Project project) {
		this.project = project;
	}
	
	
}
